Skip to content

fix: add cy.then timeouts to cy.session #31788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 30, 2025

Conversation

mschile
Copy link
Contributor

@mschile mschile commented May 27, 2025

Additional details

We've observed cases where the load event for navigating to about:blank has taken more than 4 seconds but does eventually resolve. This can cause the cy.session command to fail since we don't define our own timeouts for the cy.then calls within cy.session. In order to resolve this issue, we are adding a timeout of 20s to the internal cy.then calls. Long term, we will probably want to investigate removing some of the internal cy.then calls since they may not be needed.

Custom debug logs showing the about:blank page taking ~6s to load:

10:59:49.7158097Z cypress:aut-iframe: Setting iframe src to about:blank
10:59:49.7171870Z cypress:useEventManager: Page loading state changed: true
10:59:56.0246856Z cypress:aut-iframe: Blank page loaded

Steps to test

  • I forced loading the about:blank page to take longer than the defaultCommandTimeout and verified it failed before and passes with the new timeouts.

How has the user experience changed?

Before:
Screenshot 2025-05-27 at 11 46 27 AM

After:
Screenshot 2025-05-27 at 11 45 18 AM

PR Tasks

@mschile mschile requested a review from Copilot May 27, 2025 18:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a 20-second timeout to various internal cy.then calls within cy.session to handle cases where navigating to about:blank takes longer than expected, addressing issue [#29496]. It also updates the aut-iframe logic to resolve the promise early when the iframe element is not present and amends the CHANGELOG accordingly.

  • Added a COMMAND_TIMEOUT constant to all cy.then calls used within session management.
  • Updated the aut-iframe promise to resolve early when necessary.
  • Updated the CHANGELOG with details of the bugfix.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/driver/src/cy/commands/sessions/index.ts Added timeouts to multiple cy.then invocations to increase robustness during session setup and restoration.
packages/app/src/runner/aut-iframe.ts Modified visitBlankPage to resolve immediately when the iframe is not available.
cli/CHANGELOG.md Updated changelog to describe the bugfix for cy.session timeouts.

Copy link

cypress bot commented May 27, 2025

cypress    Run #62745

Run Properties:  status check passed Passed #62745  •  git commit 488a32f79c: Merge branch 'develop' into mschile/sessions/update_timeout
Project cypress
Branch Review mschile/sessions/update_timeout
Run status status check passed Passed #62745
Run duration 08m 40s
Commit git commit 488a32f79c: Merge branch 'develop' into mschile/sessions/update_timeout
Committer Matt Schile
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 85
View all changes introduced in this branch ↗︎
UI Coverage  41.79%
  Untested elements 36  
  Tested elements 28  
Accessibility  91.43%
  Failed rules  0 critical   4 serious   0 moderate   0 minor
  Failed elements 94  

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whew, that's a lot of thens 😞

mschile and others added 2 commits May 28, 2025 12:35
@mschile mschile merged commit 68469a6 into develop May 30, 2025
90 of 91 checks passed
@mschile mschile deleted the mschile/sessions/update_timeout branch May 30, 2025 16:47
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 3, 2025

Released in 14.4.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v14.4.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cy.session failure that didn't come from my code
3 participants